#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct FenwickTree {
	int *a;
	int *b;
	int n;
} FenwickTree;


static int
rsq_(FenwickTree *fwt, register int idx)
{
	int sum = 0;
	while (idx >= 0) {
		sum += fwt->b[idx];
		idx = (idx & (idx + 1)) - 1;
	}
	return sum;
}

int
rsq(FenwickTree *fwt, int l, int r)
{
	return rsq_(fwt, r) - rsq_(fwt, l-1);
}

void
update(FenwickTree *fwt, register int idx, int diff)
{
	while (idx < fwt->n) {
		fwt->b[idx] += diff;
		idx = idx | (idx + 1);
	}
}

int
get_median(FenwickTree *ft)
{
	int L = 0,
	    R = ft->n - 1,
	    M = (L + R) / 2,
	    n_elem_diff;

	while (L < R) {
		n_elem_diff = rsq(ft, 0, M) - rsq(ft, M+1, ft->n - 1);
		if (n_elem_diff < 0)
			L = M+1;
		else if (n_elem_diff > 0)
			R = M;
		else
			break;
		M = (L + R) / 2;
		(void) fprintf(stderr, "L=%d M=%d R=%d\n", L, M, R);
	}

	(void) fprintf(stderr, "get_median() returns "
			"M=%d ft->a[M]=%d\n",
			M, ft->a[M]);
	return M;
}

int
main(void)
{
	FenwickTree counts_array;
	char buf[256];
	int n_iter;
	int x;

	counts_array.n = (int) 1e+5;
	counts_array.a = (int*) calloc((size_t) 1e+5+1, sizeof(int));
	counts_array.b = (int*) calloc((size_t) 1e+5+1, sizeof(int));
	if (!counts_array.a || !counts_array.b) {
		(void) fprintf(stderr, "Failed to allocate %lu bytes\n"
				"Exiting\n",
				sizeof(int) * 200002);
		return 1;
	}
	(void) scanf("%d", &n_iter);
	while (scanf("%s%d", buf, &x) == 2) {
		if (!strcmp(buf, "Insert")) {
			counts_array.a[x]++;
			update(&counts_array, x,  1);
		} else if (!strcmp(buf, "Delete")) {
			counts_array.a[x]--;
			update(&counts_array, x, -1);
		}
		(void) printf("%d\n", get_median(&counts_array));
	}

	free(counts_array.a);
	free(counts_array.b);
	return 0;
}
